package clem;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JScrollPane;

public class MainWindow extends JFrame {
  private static final long serialVersionUID = 1L;
  private BeanTable<Coso> tblDati;
  
  public MainWindow() {
    super("CRUD");
    inizializzaComponenti();
  }
  
  public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
      @Override
      public void run() {
        new MainWindow().setVisible(true);
      }
    });
    
  }
  
  private void inizializzaComponenti() {
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    
    tblDati  = new BeanTable<Coso>(Coso.getElencoTest());
    tblDati.addBeanColumn("Nome", String.class, "nome",false);
    tblDati.addBeanColumn("Cognome", String.class, "cognome");
    tblDati.updateModel();
    
    JScrollPane scrollPane = new JScrollPane(tblDati);
    setLayout(new BorderLayout());
    add(scrollPane, BorderLayout.CENTER);
    scrollPane.setViewportView(tblDati);
    scrollPane.setPreferredSize(new Dimension(200,200));
    pack();
  }
  
}
